// index.js
const audioCtx = wx.createWebAudioContext()
const api = require("../../api/index");
Page({
  data: {
    list: [
      { "site_name": "五角大楼","site_time":"8:00-17:00"},
      { "site_name": "五角大楼","site_time":"8:00-17:00" },
      { "site_name": "五角大楼","site_time":"8:00-17:00" }
    ],
    home_title:"生命在于运动"
  },
  myshow(){
    console.log("hello");
    wx.vibrateShort({
      type: 'heavy',
    })
  },
onReady(){
  api.getMsg().then(data => 
    console.log(data)  
  )
},
onShow(){
   wx.request({
    url: 'http://192.168.0.14/config/getValue?system_key=home_title',
    success:(data) => {
      console.log(data.data.data);
      this.setData({
        home_title:data.data.data[0].system_value
      })
    }
  });
},
loadAudio(url){
  return new Promise((resolve) => {
    wx.request({
      url,
      responseType: 'arraybuffer',
      success: res => {
        console.log('res.data', res.data)
        audioCtx.decodeAudioData(res.data, buffer => {
          resolve(buffer)
        }, err => {
          console.error('decodeAudioData fail', err)
          reject()
        })
      },
      fail: res => {
        console.error('request fail', res)
        reject()
      }
    })
  })
},
  jumpTo(){
    wx.navigateTo({
      url: '/scondary_page/details_jump/details_jump',
    })
  }
})
